<?php
/**
 * Created by PhpStorm.
 * User: xpz
 * Date: 2022/11/1
 * Time: 13:24
 */
namespace app\admin\controller\record;
use app\common\controller\Backend;
use think\Db;
class Record extends Backend
{
    protected $model = null;
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Record');

    }


    public function del($ids = "")
    {
        if (!$this->request->isPost()) {
            $this->error(__("Invalid parameters"));
        }
        $ids = $ids ? $ids : $this->request->post("ids");
//        print_r($ids);exit;
        if ($ids) {
//            $pk = $this->model->getPk();
//            $adminIds = $this->getDataLimitAdminIds();
//            if (is_array($adminIds)) {
//                $this->model->where($this->dataLimitField, 'in', $adminIds);
//            }
//            $list = $this->model->where($pk, 'in', $ids)->select();

//            $count = 0;
            Db::startTrans();
            try {
                $rs = $this->model->where(['id'=>$ids])->update(['status'=>2]);
                Db::commit();
            } catch (PDOException $e) {
                Db::rollback();
                $this->error($e->getMessage());
            } catch (Exception $e) {
                Db::rollback();
                $this->error($e->getMessage());
            }
            if ($rs) {
                $this->success();
            } else {
                $this->error(__('No rows were deleted'));
            }
        }
        $this->error(__('Parameter %s can not be empty', 'ids'));
    }

}